USE JICCDB
GO
CREATE PROC proc_AddUser
@LoginID	VARCHAR(16),
@Password	VARCHAR(20),
@NickName	VARCHAR(16),
@Name		VARCHAR(5),
@Phone		VARCHAR(15),
@Sex		CHAR(2),
@Birthday	VARCHAR(10),
@Email		VARCHAR(50),
@Address	VARCHAR(100),
@DptName	VARCHAR(10),
@UserPhoto	VARCHAR(50),
@Memo		VARCHAR(150)
AS

DECLARE @count int
SELECT @count = COUNT(*) FROM tab_User WHERE LoginID = @LoginID
IF(@count  > 0)
BEGIN
RETURN(2)
END
ELSE
BEGIN
DECLARE @dptID INT
SELECT @dptID = DptID FROM tab_Department WHERE DptName = @DptName
INSERT tab_User VALUES(@LoginID, @Password, @NickName, @Name, @Phone, @Sex, 
@Birthday, @Email, @Address, @DptID, @UserPhoto, @Memo)
RETURN(0)
END
RETURN(1)
GO